package com.newly.api.sys.feign;

import com.newly.common.base.constants.ServerUriConstant;
import com.newly.common.base.entity.R;
import com.newly.common.base.entity.sys.loginRecord.dto.LoginRecordDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author gjm guan
 * @date 2021/9/1 15:47
 * @desc 登录记录接口
 */
@Api(tags = "登录记录api")
@FeignClient(path = ServerUriConstant.NEWLY_SYS_LOGIN_RECORD, name = ServerUriConstant.NEWLY_SYS_SERVICE_NAME)
public interface LoginRecordClient {

    @ApiOperation("添加登录历史")
    @PostMapping("/create")
    R create(@RequestBody LoginRecordDto loginRecordDto);

    @ApiOperation("查询登录历史")
    @GetMapping("/list")
    R list(@NotNull(message = "offset can't be empty") @RequestParam("offset") Integer offset,
           @NotNull(message = "limit can't be empty") @RequestParam("limit") Integer limit,
           @RequestParam(value = "fromTime", required = false) String fromTime,
           @RequestParam(value = "toTime", required = false) String toTime,
           @RequestParam(value = "keyword", required = false) String keyword);

    @ApiOperation("通过id查询登录历史")
    @GetMapping("queryById")
    R queryById(@NotNull(message = "loginRecordId can't be empty")
                @RequestParam("loginRecordId") Long loginRecordId);

    @ApiOperation("通过id删除登录历史")
    @DeleteMapping("/deleteByIds")
    R deleteByIds(@NotEmpty(message = "loginRecordIds can't be empty")
                  @RequestParam("loginRecordIds") List<Long> loginRecordIds);

    @ApiOperation("清空登录历史")
    @DeleteMapping("/clear")
    R clear();

}
